package com.ruoyi.web.controller.medicine;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.medicine.domain.HisMedicineOrderAudit;
import com.ruoyi.medicine.service.IHisMedicineOrderAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 审核信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/system/audit")
public class HisMedicineOrderAuditController extends BaseController
{
    @Autowired
    private IHisMedicineOrderAuditService hisMedicineOrderAuditService;


    /**
     * 查询审核信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisMedicineOrderAudit hisMedicineOrderAudit)
    {
        startPage();
        List<HisMedicineOrderAudit> list = hisMedicineOrderAuditService.selectHisMedicineOrderAuditList(hisMedicineOrderAudit);
        return getDataTable(list);
    }

    /**
     * 导出审核信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:export')")
    @Log(title = "审核信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HisMedicineOrderAudit hisMedicineOrderAudit)
    {
        List<HisMedicineOrderAudit> list = hisMedicineOrderAuditService.selectHisMedicineOrderAuditList(hisMedicineOrderAudit);
        ExcelUtil<HisMedicineOrderAudit> util = new ExcelUtil<HisMedicineOrderAudit>(HisMedicineOrderAudit.class);
        util.exportExcel(response, list, "审核信息数据");
    }

    /**
     * 获取审核信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:query')")
    @GetMapping(value = "/{auditId}")
    public AjaxResult getInfo(@PathVariable("auditId") Long auditId)
    {
        return success(hisMedicineOrderAuditService.selectHisMedicineOrderAuditByAuditId(auditId));
    }

    /**
     * 新增审核信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:add')")
    @Log(title = "审核信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisMedicineOrderAudit hisMedicineOrderAudit)
    {
        return toAjax(hisMedicineOrderAuditService.insertHisMedicineOrderAudit(hisMedicineOrderAudit));
    }

    /**
     * 修改审核信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:edit')")
    @Log(title = "审核信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisMedicineOrderAudit hisMedicineOrderAudit)
    {
        return toAjax(hisMedicineOrderAuditService.updateHisMedicineOrderAudit(hisMedicineOrderAudit));
    }

    /**
     * 删除审核信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:remove')")
    @Log(title = "审核信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{auditIds}")
    public AjaxResult remove(@PathVariable Long[] auditIds)
    {
        return toAjax(hisMedicineOrderAuditService.deleteHisMedicineOrderAuditByAuditIds(auditIds));
    }
}
